use axum_app_dao::{
    entity::sys_user,
    user_dal::{UserQuery, UserQueryCondition},
};
use sea_orm::{Database, Order};

#[tokio::test]
async fn test_user() {
    let conn = Database::connect("mysql://admin:123123@10.43.77.183:3306/demo")
        .await
        .expect("Database connection failed");

    println!("connect OK ..");

    let user = UserQuery::find_user_by_id(&conn, 2).await;

    println!("user={:?}", user);
}

#[tokio::test]
async fn test_query_pages() {
    tracing_subscriber::fmt()
        .with_max_level(tracing::Level::DEBUG)
        .with_test_writer()
        .init();

    let conn = Database::connect("mysql://admin:123123@10.43.77.183:3306/demo")
        .await
        .expect("Database connection failed");

    let params = UserQueryCondition::new(vec![(sys_user::Column::Id, Order::Asc)])
        .display_name_left_like(Some("孙"))
        .username_eq(Some("sunkai"));

    println!("connect OK ..");
    let query = UserQuery::query_page(&conn, 1, 2, params).await;

    let users = query.items;
    println!("users:{:?}", users);
}
